package config

import (
	"gitee.com/xiaoyutab/xgotool/xgodb/xgodbconfig"
	"gitee.com/xiaoyutab/xgotool/xstring"
)

// 初始化配置信息
func configure() {
	xgodbconfig.GroupInserts([]xgodbconfig.ConfigureGroup{
		{Id: 1, Fid: 0, NameGroup: "APP", NameGroupCn: "程序配置"},
		{Id: 100, Fid: 1, NameGroup: "NSQ", NameGroupCn: "NSQ队列配置"},
		{Id: 101, Fid: 1, NameGroup: "REDIS", NameGroupCn: "Redis配置"},
		{Id: 102, Fid: 1, NameGroup: "USER", NameGroupCn: "用户相关"},
	})
	xgodbconfig.InsertsOrContinue([]xgodbconfig.Configure{
		{NameKey: "NSQ_SET", NameCn: "设置连接", NameGroup: "NSQ", Types: "string", Desc: "NSQ设置队列，修改后请重启服务以转接到新的队列服务中"},
		{NameKey: "NSQ_SET_TOPIC", NameCn: "设置Topic", NameGroup: "NSQ", Types: "string", Desc: "NSQ设置Topic，修改后请重启服务以转接到新的队列服务中", ValueString: "golang-xnsq"},
		{NameKey: "NSQ_GET", NameCn: "获取连接", NameGroup: "NSQ", Types: "string", Desc: "NSQ获取队列，修改后请重启服务以转接到新的队列服务中"},
		{NameKey: "NSQ_GET_TOPIC", NameCn: "获取topic", NameGroup: "NSQ", Types: "string", Desc: "NSQ获取topic，修改后请重启服务以转接到新的队列服务中", ValueString: "golang-xnsq"},
		{NameKey: "NSQ_GET_CHANNEL", NameCn: "获取Channel", NameGroup: "NSQ", Types: "string", Desc: "NSQ获取Channel，修改后请重启服务以转接到新的队列服务中", ValueString: "xnsq-channel"},
		{NameKey: "NSQ_GET_MAX_IN_FLIGHT", NameCn: "通道并发", NameGroup: "NSQ", Types: "int", Desc: "NSQ队列的MaxInFlight，修改后请重启服务以转接到新的队列服务中", ValueInt: 1},
		{NameKey: "NSQ_GET_MAX_ATTEMPTS", NameCn: "通道重试", NameGroup: "NSQ", Types: "int", Desc: "NSQ队列错误重试次数，修改后请重启服务以转接到新的队列服务中", ValueInt: 6},
		{NameKey: "NSQ_STATUS", NameCn: "开启状态", NameGroup: "NSQ", Types: "bool", Desc: "如果关闭此配置项，则不再使用NSQ队列进行任务监听，直接使用go xxxx进行携程执行", ValueBool: 1},
		{NameKey: "REDIS_STSTUS", NameCn: "开启状态", NameGroup: "REDIS", Types: "bool", Desc: "是否开启Redis缓存 开-使用程序缓存+Redis缓存，关-仅使用程序缓存", ValueBool: 0},
		{NameKey: "REDIS_HOST", NameCn: "服务地址", NameGroup: "REDIS", Types: "string", Desc: "Redis缓存服务器的地址，需携带端口号，格式：127.0.0.1:6379 或者 [::]:6379", ValueString: ""},
		{NameKey: "REDIS_PASS", NameCn: "服务密码", NameGroup: "REDIS", Types: "string", Desc: "Redis缓存服务器的连接密码信息"},
		{NameKey: "REDIS_NUM", NameCn: "查询库", NameGroup: "REDIS", Types: "int", Desc: "查询的Redis数据库，类似于cli命令行中的 select x"},
		{NameKey: "USER_REGEDIT", NameCn: "注册开关", NameGroup: "USER", Types: "bool", Desc: "是否开启用户注册功能", ValueBool: 0},
		{NameKey: "USER_PASS_UP", NameCn: "密码含大写字母", NameGroup: "USER", Types: "bool", Desc: "用户密码必须含有大写字母？", ValueBool: 1},
		{NameKey: "USER_PASS_LOW", NameCn: "密码含小写字母", NameGroup: "USER", Types: "bool", Desc: "用户密码必须含有小写字母？", ValueBool: 1},
		{NameKey: "USER_PASS_NUM", NameCn: "密码含数字", NameGroup: "USER", Types: "bool", Desc: "用户密码必须含有数字？", ValueBool: 1},
		{NameKey: "USER_PASS_CODE", NameCn: "密码含特殊字符", NameGroup: "USER", Types: "bool", Desc: "用户密码必须含有特殊字符？", ValueBool: 1},
		{NameKey: "USER_PASS_MIN", NameCn: "密码最小位数", NameGroup: "USER", Types: "int", Desc: "用户密码输入的最小位数（含）", ValueInt: 8},
		{NameKey: "USER_PASS_MAX", NameCn: "密码最大位数", NameGroup: "USER", Types: "int", Desc: "用户密码输入的最大位数（含）", ValueInt: 32},
		{NameKey: "USER_RAND_PASS", NameCn: "密码随机串", NameGroup: "USER", Types: "string", Desc: "用户密码加密的随机字符串，为了避免修改此值后用户无法再次登录问题，此处随机串只取前12位，且将该值存储到用户的随机串中去", ValueString: xstring.Random(12)},
		{NameKey: "USER_ERROR_LOCK", NameCn: "密码错误次数", NameGroup: "USER", Types: "int", Desc: "用户密码输入错误多少次后锁定", ValueInt: 5},
		{NameKey: "USER_LOCK_TIME", NameCn: "锁定时长", NameGroup: "USER", Types: "int", Desc: "用户密码输入错误多少次后锁定时长，单位：秒", ValueInt: 60 * 60 * 24},
	})
}
